var getRootPath = function () {
    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPaht = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/uimcardprj
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    return (localhostPaht + projectName + '/');
  };
  Date.prototype.format = function(fmt) { 
	     var o = { 
	        "M+" : this.getMonth()+1,                 //月份 
	        "d+" : this.getDate(),                    //日 
	        "h+" : this.getHours(),                   //小时 
	        "m+" : this.getMinutes(),                 //分 
	        "s+" : this.getSeconds(),                 //秒 
	        "q+" : Math.floor((this.getMonth()+3)/3), //季度 
	        "S"  : this.getMilliseconds()             //毫秒 
	    }; 
	    if(/(y+)/.test(fmt)) {
	            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	    }
	     for(var k in o) {
	        if(new RegExp("("+ k +")").test(fmt)){
	             fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
	         }
	     }
	    return fmt; 
	}
  //默认三天
  function getDay(day){
	    var today = new Date();
	    var targetday_milliseconds=today.getTime() + 1000*60*60*24*day;
	    today.setTime(targetday_milliseconds); //注意，这行是关键代码
	    var tYear = today.getFullYear();
	    var tMonth = today.getMonth();
	    var tDate = today.getDate();
	    tMonth = doHandleMonth(tMonth + 1);
	    tDate = doHandleMonth(tDate);
	    return tYear+"-"+tMonth+"-"+tDate;
	}
	function doHandleMonth(month){
	    var m = month;
	    if(month.toString().length == 1){
	     m = "0" + month;
	    }
	    return m;
	}
/**
 * @params data是当前时间
 * @params monthNum 可以传负数，表示当前日期往后几个月
 *
 */

  function GetPreMonthDay (date){
	  console.log(typeof date)
	  var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]);      
	  	var strYear = date.getFullYear();        
	    var strDay = date.getDate();        
	    var strMonth = date.getMonth()+1;      
	    if(strYear%4 == 0 && strYear%100 != 0){      
	       daysInMonth[2] = 29;      
	    }      
	    if(strMonth - 1 == 0)      
	    {      
	       strYear -= 1;      
	       strMonth = 12;      
	    }      
	    else     
	    {      
	       strMonth -= 1;      
	    }      
	    strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth];      
	    if(strMonth<10)        
	    {        
	       strMonth="0"+strMonth;        
	    }      
	    if(strDay<10)        
	    {        
	       strDay="0"+strDay;        
	    }      
	    datastr = strYear+"-"+strMonth+"-"+strDay+" 00:00:00";      
	    return datastr;      
  }
  
//删除数组指定项
Array.prototype.del = function (n) {  
	if (n < 0)         
		return this;   
	else return this.slice(0, n).concat(this.slice(n + 1, this.length));
	}
 

//解析url参数

function GetRequest() {   
	   var url = location.search; //获取url中"?"符后的字串   
	   var theRequest = new Object();   
	   if (url.indexOf("?") != -1) {   
	      var str = url.substr(1);   
	      strs = str.split("&");   
	      for(var i = 0; i < strs.length; i ++) {   
	         theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);   
	      }   
	   }   
	   return theRequest;   
	}   


